# Maintainer: Filipe Laíns (ffy00) <lains@archlinux.org>

pkgname=at51
pkgver=1.0.0
pkgrel=4
pkgdesc='Applications for reverse engineering architecture 8051 firmware'
arch=(loong64 x86_64)
url=https://github.com/8051Enthusiast/at51
license=(MIT)
depends=(
  gcc-libs
  glibc
)
makedepends=(
  rust
  cargo
)
source=($url/archive/$pkgver/$pkgname-$pkgver.tar.gz)
sha512sums=('41bdd9357e8d6a4e385187a6371e94cbbf91ef907d13216c6b1807dae4c84da28552dc35e46f4247e21dcbce6eb3013d2c6e70c1f97b00d740618e71d565c117')
b2sums=('3bb3793c2082fa4ce2973bd4c58ff684ebe6afdcf1507d112a0a9c89e8410bda8493d1346c939d24e80896b24151123b15d9f20c97d66ddab7e7455f470dca1d')

prepare() {
  cd $pkgname-$pkgver
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}
build() {
  cd $pkgname-$pkgver
  export RUSTUP_TOOLCHAIN=stable
  export CARGO_TARGET_DIR=target
  cargo build --frozen --release --all-features
}

check() {
  cd $pkgname-$pkgver
  export RUSTUP_TOOLCHAIN=stable
  cargo test --frozen --all-features
}

package() {
  cd $pkgname-$pkgver

  install -Dm 755 target/release/$pkgname -t "$pkgdir"/usr/bin/
  install -Dm 644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}

